package com.atguigu.gulimall.order.controller;

import com.atguigu.gulimall.order.biz.OrderBizService;
import com.atguigu.gulimall.ware.WareStockMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author nicc
 * @version 1.0
 * @className OrderSpiltController
 * @date 2022-10-27 13:39
 *
 * 拆单控制器
 */
@RestController
@RequestMapping("/api/order")
public class OrderSpiltController {


    @Autowired
    OrderBizService orderBizService;

    /**
     * 由库存系统在需要拆单的时候发起远程调用进行拆单
     * @return
     */
    @PostMapping("/orderSplit")
    public List<WareStockMsg> orderSpilt(@RequestParam("orderId") Long orderId,
                                         @RequestParam("wareSkuMap") String wareSkuMapJson){

        //返回拆分后的所有小单
        List<WareStockMsg> msgs = orderBizService.splitOrder(orderId,wareSkuMapJson);
        return msgs;
    }
}
